.class public Lcom/glympse/platform/common/JobQueue$JobQueueThread;
.super Ljava/lang/Thread;
.source "JobQueue.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/glympse/platform/common/JobQueue;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x4
    name = "JobQueueThread"
.end annotation


# instance fields
.field protected m_oThreadExited:Lcom/glympse/platform/common/SignaledObject;

.field final synthetic this$0:Lcom/glympse/platform/common/JobQueue;


# direct methods
.method protected constructor <init>(Lcom/glympse/platform/common/JobQueue;)V
    .locals 1
    .parameter

    .prologue
    .line 215
    iput-object p1, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    .line 212
    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    .line 203
    new-instance v0, Lcom/glympse/platform/common/SignaledObject;

    invoke-direct {v0}, Lcom/glympse/platform/common/SignaledObject;-><init>()V

    iput-object v0, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->m_oThreadExited:Lcom/glympse/platform/common/SignaledObject;

    .line 214
    invoke-virtual {p0}, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->start()V

    return-void
.end method

.method protected constructor <init>(Lcom/glympse/platform/common/JobQueue;Ljava/lang/String;)V
    .locals 1
    .parameter
    .parameter "strThreadName"

    .prologue
    .line 209
    iput-object p1, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    .line 208
    invoke-direct {p0, p2}, Ljava/lang/Thread;-><init>(Ljava/lang/String;)V

    .line 203
    new-instance v0, Lcom/glympse/platform/common/SignaledObject;

    invoke-direct {v0}, Lcom/glympse/platform/common/SignaledObject;-><init>()V

    iput-object v0, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->m_oThreadExited:Lcom/glympse/platform/common/SignaledObject;

    return-void
.end method


# virtual methods
.method public run()V
    .locals 6

    .prologue
    .line 224
    :cond_0
    :goto_0
    :try_start_0
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-boolean v3, v3, Lcom/glympse/platform/common/JobQueue;->m_fExitThreads:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    if-eqz v3, :cond_2

    .line 290
    :cond_1
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->m_oThreadExited:Lcom/glympse/platform/common/SignaledObject;

    invoke-virtual {v3}, Lcom/glympse/platform/common/SignaledObject;->Signal()V

    .line 292
    :goto_1
    return-void

    .line 227
    :cond_2
    :try_start_1
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v3, v3, Lcom/glympse/platform/common/JobQueue;->m_oSemaphore:Lcom/glympse/platform/common/SignaledObject;

    invoke-virtual {v3}, Lcom/glympse/platform/common/SignaledObject;->WaitForSignal()Z

    .line 230
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-boolean v3, v3, Lcom/glympse/platform/common/JobQueue;->m_fExitThreads:Z

    if-nez v3, :cond_1

    .line 236
    const/4 v2, 0x0

    .line 237
    .local v2, oJob:Lcom/glympse/platform/common/JobQueue$Job;
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v4, v3, Lcom/glympse/platform/common/JobQueue;->m_listJobsPending:Lcom/glympse/platform/GVector$Jobs;

    monitor-enter v4
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 239
    :try_start_2
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v3, v3, Lcom/glympse/platform/common/JobQueue;->m_listJobsPending:Lcom/glympse/platform/GVector$Jobs;

    invoke-virtual {v3}, Lcom/glympse/platform/GVector$Jobs;->isEmpty()Z

    move-result v3

    if-nez v3, :cond_3

    .line 241
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v3, v3, Lcom/glympse/platform/common/JobQueue;->m_listJobsPending:Lcom/glympse/platform/GVector$Jobs;

    invoke-virtual {v3}, Lcom/glympse/platform/GVector$Jobs;->firstElement()Ljava/lang/Object;

    move-result-object v3

    move-object v0, v3

    check-cast v0, Lcom/glympse/platform/common/JobQueue$Job;

    move-object v2, v0

    .line 242
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v3, v3, Lcom/glympse/platform/common/JobQueue;->m_listJobsPending:Lcom/glympse/platform/GVector$Jobs;

    const/4 v5, 0x0

    invoke-virtual {v3, v5}, Lcom/glympse/platform/GVector$Jobs;->removeElementAt(I)V

    .line 243
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v3, v3, Lcom/glympse/platform/common/JobQueue;->m_listJobsRunning:Lcom/glympse/platform/GVector$Jobs;

    invoke-virtual {v3, v2}, Lcom/glympse/platform/GVector$Jobs;->addElement(Ljava/lang/Object;)V

    .line 237
    :cond_3
    monitor-exit v4
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 247
    if-eqz v2, :cond_0

    .line 251
    :try_start_3
    invoke-virtual {v2}, Lcom/glympse/platform/common/JobQueue$Job;->OnProcess()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_1

    .line 259
    :goto_2
    :try_start_4
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v3, v3, Lcom/glympse/platform/common/JobQueue;->m_listJobsPending:Lcom/glympse/platform/GVector$Jobs;

    monitor-enter v3
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0

    .line 261
    :try_start_5
    iget-object v4, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    iget-object v4, v4, Lcom/glympse/platform/common/JobQueue;->m_listJobsRunning:Lcom/glympse/platform/GVector$Jobs;

    invoke-virtual {v4, v2}, Lcom/glympse/platform/GVector$Jobs;->removeElement(Ljava/lang/Object;)Z

    .line 259
    monitor-exit v3
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_2

    .line 264
    :try_start_6
    iget-boolean v3, v2, Lcom/glympse/platform/common/JobQueue$Job;->m_fCompleteOnMainThread:Z

    if-eqz v3, :cond_4

    .line 266
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v3

    new-instance v4, Lcom/glympse/platform/common/JobQueue$CompleteJobOnMainThread;

    invoke-direct {v4, v2}, Lcom/glympse/platform/common/JobQueue$CompleteJobOnMainThread;-><init>(Lcom/glympse/platform/common/JobQueue$Job;)V

    invoke-virtual {v3, v4}, Lcom/glympse/platform/Platform;->PostToMainThread(Lcom/glympse/platform/GRunnable;)Z
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_0

    goto :goto_0

    .line 284
    .end local v2           #oJob:Lcom/glympse/platform/common/JobQueue$Job;
    :catch_0
    move-exception v3

    move-object v1, v3

    .line 286
    .local v1, e:Ljava/lang/Exception;
    :try_start_7
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_1

    .line 290
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->m_oThreadExited:Lcom/glympse/platform/common/SignaledObject;

    invoke-virtual {v3}, Lcom/glympse/platform/common/SignaledObject;->Signal()V

    goto :goto_1

    .line 237
    .end local v1           #e:Ljava/lang/Exception;
    .restart local v2       #oJob:Lcom/glympse/platform/common/JobQueue$Job;
    :catchall_0
    move-exception v3

    :try_start_8
    monitor-exit v4
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_0

    :try_start_9
    throw v3
    :try_end_9
    .catchall {:try_start_9 .. :try_end_9} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_9 .. :try_end_9} :catch_0

    .line 289
    .end local v2           #oJob:Lcom/glympse/platform/common/JobQueue$Job;
    :catchall_1
    move-exception v3

    .line 290
    iget-object v4, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->m_oThreadExited:Lcom/glympse/platform/common/SignaledObject;

    invoke-virtual {v4}, Lcom/glympse/platform/common/SignaledObject;->Signal()V

    .line 291
    throw v3

    .line 253
    .restart local v2       #oJob:Lcom/glympse/platform/common/JobQueue$Job;
    :catch_1
    move-exception v1

    .line 255
    .restart local v1       #e:Ljava/lang/Exception;
    :try_start_a
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V
    :try_end_a
    .catchall {:try_start_a .. :try_end_a} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_a .. :try_end_a} :catch_0

    goto :goto_2

    .line 259
    .end local v1           #e:Ljava/lang/Exception;
    :catchall_2
    move-exception v4

    :try_start_b
    monitor-exit v3
    :try_end_b
    .catchall {:try_start_b .. :try_end_b} :catchall_2

    :try_start_c
    throw v4

    .line 270
    :cond_4
    const/4 v3, 0x0

    iput-object v3, v2, Lcom/glympse/platform/common/JobQueue$Job;->m_oJobQueue:Lcom/glympse/platform/common/JobQueue;
    :try_end_c
    .catchall {:try_start_c .. :try_end_c} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_c .. :try_end_c} :catch_0

    .line 274
    :try_start_d
    iget-object v3, p0, Lcom/glympse/platform/common/JobQueue$JobQueueThread;->this$0:Lcom/glympse/platform/common/JobQueue;

    invoke-virtual {v2, v3}, Lcom/glympse/platform/common/JobQueue$Job;->OnComplete(Lcom/glympse/platform/common/JobQueue;)V
    :try_end_d
    .catchall {:try_start_d .. :try_end_d} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_d .. :try_end_d} :catch_2

    goto/16 :goto_0

    .line 276
    :catch_2
    move-exception v3

    move-object v1, v3

    .line 278
    .restart local v1       #e:Ljava/lang/Exception;
    :try_start_e
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V
    :try_end_e
    .catchall {:try_start_e .. :try_end_e} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_e .. :try_end_e} :catch_0

    goto/16 :goto_0
.end method
